package com.auz.datagenerator.launcher;

import java.util.Hashtable;

import com.auz.datagenerator.connector.AbstractConnector;
import com.auz.datagenerator.connector.Type;
import com.auz.datagenerator.connector.TypeHandler;
import com.auz.datagenerator.connector.heuristiclink.ValueHeuristicLink;
import com.auz.datagenerator.heuristics.time.IIntervalHeuristic;
import com.auz.datagenerator.heuristics.time.SetIntervalHeuristic;
import com.auz.datagenerator.heuristics.value.BaseValueHeuristic;
import com.auz.datagenerator.heuristics.value.CardinalDirectionHeuristic;
import com.auz.datagenerator.heuristics.value.IValueHeuristic;
import com.auz.datagenerator.publishing.FilePublisher;
import com.auz.datagenerator.publishing.IPublisher;

public class DirectionExample {

	public static void main(String[] args) {
		// Create the direction heuristic
		CardinalDirectionHeuristic direction = new CardinalDirectionHeuristic("");
		BaseValueHeuristic value = new BaseValueHeuristic(100);
		
		Hashtable<String, IValueHeuristic> map = new Hashtable<String, IValueHeuristic>();
		// Add the heuristic to a map and assign to an identifier
		map.put("direction", direction);
		map.put("base", value);
		
		// Create a heuristic link for this mapping
		ValueHeuristicLink link = new ValueHeuristicLink(map);
		link.setEquation("$direction$.$base$");
		
		// Create a publisher; in this case a server
		IPublisher publisher = new FilePublisher("../published.txt");
		// Create a timer
		IIntervalHeuristic timer = new SetIntervalHeuristic(1000);
		
		TypeHandler handler = new TypeHandler(Type.STRING);
		// Connect the value heuristic link to the timer and the publisher
		AbstractConnector c = new AbstractConnector(timer, link, publisher, handler);
		// Run
		c.run();
	}
	
}
